<?php

class DMLGenerator{

	public static  function createInsert($tabela,$attr = array(),$prefixo=""){

		foreach($attr as $chave => $valor){
				
			$campos[] = $prefixo.$chave;
			$valores[] = "'".str_replace("'","\"",$valor)."'";

		}

		$insert = "insert into ".$tabela." (".implode($campos,",").") values ( ".implode($valores,",").");";

		return $insert;
	}

	public static  function createUpdate($tabela,$attr = array(),$prefixo=""){

		$id = $attr['id'];
		foreach($attr as $chave => $valor){

				
			$atualiza[] = $prefixo.$chave." = '".str_replace("'","\"",$valor)."'";

		}

		$update = "update $tabela set ".implode($atualiza,",")." where ".$prefixo."id = $id;";
		return $update;
	}
	
	public static  function createDelete($tabela,$id,$prefixo){
		
		$delete = "delete from $tabela where ".$prefixo."id=".$id.";";
	
		return $delete;
	}
}

?>